import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-31
 * Time: 8:12
 */
class Student implements Cloneable {
    public String name;

    public Student(String name) {
        this.name = name;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test {
    public static void test2() {
        int a  =0;
        Scanner scanner = new Scanner(System.in);
        try {
            System.out.print("请输入a的值：");
            a = scanner.nextInt();
            System.out.println(10/a);
            return;
        }/*catch (InputMismatchException e) {
            e.printStackTrace();
        }*/catch (NullPointerException e) {
            e.printStackTrace();
        }finally {
            System.out.println("finally中的代码被执行.....");
            scanner.close();
        }
    }

    public static void main(String[] args) {
        test2();
    }
    public static void test1() {
        try {
            int[] arr = {1,2,3,4};
            System.out.println(arr[10]);
            int a = 0;
            System.out.println(10/a);
        }catch (IndexOutOfBoundsException e) {
            System.out.println("捕获到了数组越界异常");
            e.printStackTrace();
        }catch (ArithmeticException e) {
            System.out.println("捕获到了算术异常");
            e.printStackTrace();
        }catch (NullPointerException e) {
            System.out.println("捕获到了空指针异常");
            e.printStackTrace();
        }
        System.out.println("执行后续代码.......");
    }

    public static void main3(String[] args) {
        test1();
    }
    public static void main2(String[] args) throws CloneNotSupportedException{
        Student student = new Student("dings");
        Student student1 = (Student) student.clone();
    }
    public static void main1(String[] args) {
        //int[] arr = {1,2,3,4};
        int[] arr = null;
        System.out.println(arr[10]);
        //System.out.println(100/0);
    }
}
